package com.hhkj.admin.order.domain;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.hhkj.admin.order.common.valid.ConfirmPayOrder;
import com.ruoyi.common.core.domain.BizBaseEntity;
import lombok.*;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 记录订单信息
 */
@EqualsAndHashCode(callSuper = true)
@TableName(value = "s_order")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Order extends BizBaseEntity {
    /** 订单号 */
    @TableField(value = "num")
    @Excel(name = "订单号", orderNum = "0", width = 20)
    private String num;

    /** 订单来源："app"-app创建 "system"-系统导入 */
    @TableField(value = "source_type_code")
    private String sourceTypeCode;

    /** 学员数量 */
    @TableField(value = "item_amount")
    @Excel(name = "学员数量", orderNum = "2", width = 20, type = 10, numFormat = "0")
    private Integer itemAmount;

    /** 应付金额 */
    @TableField(value = "price")
    @Excel(name = "应付金额（元）", orderNum = "4", width = 20, type = 10, numFormat = "#,##0.00")
    private BigDecimal price;

    /** paying-待付款，paidAuditing-支付审核中，paid-已支付，cancel-已取消 */
    @TableField(value = "status_code")
    private String statusCode;

    /** 支付方式："alipay"-支付宝 "wechat"-微信 "offline"-线下 */
    @TableField(value = "pay_method_code")
    private String payMethodCode;

    /** 支付账号 */
    @TableField(value = "pay_account")
    private String payAccount;

    /** 支付时间 */
    @TableField(value = "pay_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
    @Excel(name = "支付时间", orderNum = "8", width = 20, format = "yyyy-MM-dd HH:mm")
    private Date payTime;

    /** 实付金额 */
    @TableField(value = "pay_price")
    @NotNull(message = "实付金额不能为空", groups = {ConfirmPayOrder.class})
    private BigDecimal payPrice;

    /** 最终订单金额 */
    @TableField(value = "final_price")
    private BigDecimal finalPrice;

    /** 支付凭证 */
    @TableField(value = "pay_receipt_url")
    private String payReceiptUrl;

    /** 支付说明 */
    @TableField(value = "pay_description")
    private String payDescription;

    /** 所属商家，关联s_sale */
    @TableField(value = "sale_id")
    private Long saleId;

    /** 固化商家，对应s_sale */
    @TableField(value = "sale_name")
    private String saleName;

    /** 固化商家，对应s_sale */
    @TableField(value = "sale_num")
    private String saleNum;

    /** 所属销售，关联s_sale */
    @TableField(value = "sale_root_id")
    private Long saleRootId;

    /** 固化销售，对应s_sale */
    @TableField(value = "sale_root_name")
    private String saleRootName;

    /** 固化销售，对应s_sale */
    @TableField(value = "sale_root_num")
    private String saleRootNum;

    /** 退款状态："refunding"-退款中 "success"-退款成功 "failed"-退款失败 "cancel"-已取消 */
    @TableField(value = "refund_status_Code")
    private String refundStatusCode;

//    /** 打款状态："non"-无退款 "pending"-待打款 "done"-已打款 */
//    @TableField(value = "receive_status_code")
//    private String receiveStatusCode;

    /** 微信支付id订单信息 */
    private String wechatPrepayId;

    /** 【微信支付订单号】 原支付交易对应的微信订单号 */
    private String transactionId;

    @Override
    @NotNull(message = "id不能为空", groups = {ConfirmPayOrder.class})
    public Long getId() {
        return super.getId();
    }
}